define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'order.order/index',
        add_url: 'order.order/add',
        edit_url: 'order.order/edit',
        delete_url: 'order.order/delete',
        export_url: 'order.order/export',
        modify_url: 'order.order/modify',
        stock_url: 'order.order/stock',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ["refresh","delete","export"],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id', search: false},
                    {field: 'order_number', title: '订单号'},
                    {field: 'user.title', title: '用户'},
                    {field: 'type', search: 'select', selectList: {"1":"托管","2":"矿机","3":"算力","4":"抵押","5":"存币","6":"P盘"}, title: '订单类型'},
                    {field: 'information', title: '订单信息', search: false},
                    {field: 'goods_type', search: 'select', selectList: {"1":"现货","2":"期货"}, title: '商品类型'},
                    {field: 'money', title: '支付金额'},
                    {field: 'number', title: '数量'},
                    {field: 'entrust_days', title: '委托天数'},
                    {field: 'status', search: 'select', selectList: {"1":"未支付","2":"待交割","3":"已发货","4":"运行中","5":"托管中","6":"运行中","7":"已平仓","8":"已赎回","9":"已完结","10":"已取消"}, title: '状态'},
                    {field: 'uid_phone', title: '手机号'},
                    {field: 'address', title: '收货地址', search: false},
                    {field: 'create_time', title: '下单时间', search: false},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="true"',
                            }, {
                                text: '发货',
                                url: init.stock_url,
                                method: 'open',
                                auth: 'stock',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                            }],
                            'delete']
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        stock:function(){
            ea.listen();
        }
    };
    return Controller;
});